#include <bits/stdc++.h>
using namespace std;

int a[100005], v[100005], d[100005], t[100005];

int read()
{
	int n = 0, d = 1;
	char c;
	while ((c = getchar()) && !isdigit(c)) {if (c == '-') d = -1;}
	if (isdigit(c)) n = (c - '0');
	while ((c = getchar()) && c <= '9' && c >= '0') {n = n * 10 + (c - '0');}
	return n * d;
}

void write(int n)
{
	if (n < 0) {n = -n; putchar('-');}
	if (n >= 10) write(n / 10);
	putchar(char(n % 10 + '0'));
}

void solve()
{
    int n = read(), m = read(), L = read(), V = read();
    int mind = L;
    for (int i = 1; i <= n; i++)
    {
        d[i] = read(), v[i] = read(), a[i] = read();
        if (v[i] > V) mind = min(mind, v[i]);
    }
    for (int i = 1; i <= m; i++)
        t[i] = read();
    sort(t + 1, t + m + 1);
    int ans = 0, temp;
    for (int i = 1; i <= n; i++)
    {
        temp = lower_bound(t + 1, t + m + 1, d[i]) - t;
        if (temp >= 1 && temp <= m && v[i] > V) ans++;
    }
    write(ans);
    putchar(' ');
    if (t[m] < mind) 
    {
        write(m);
        putchar('\n');
        return;
    }
    write(m - 1);
    putchar('\n');
}

int main()
{
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	int T = read();
	while (T--) solve();
	return 0;
}